package tank.explosion;

import gameBasics.GameModel;
import gameBasics.GameObject;
import gameBasics.ResourceManager;
import java.awt.*;

public class Explosion extends GameObject {

    public static final int WIDTH = ResourceManager.explosions[0].getWidth();   //爆炸的宽度
    public static final int HEIGHT = ResourceManager.explosions[0].getHeight(); //爆炸的高度
    private int step = 0;                       //爆炸图片组的位置

    //有参构造方法
    public Explosion(int x, int y){
        this.x = x;
        this.y = y;

        GameModel.getInstance().addGameObject(this);
    }

    /**
     * 绘制爆炸
     */
    public void paint(Graphics graphics){
        graphics.drawImage(ResourceManager.explosions[step++],x,y,null);
        if(step >= ResourceManager.explosions.length) GameModel.getInstance().removeGameObject(this);
    }

    @Override
    public int getWidth() {
        return WIDTH;
    }

    @Override
    public int getHeight() {
        return HEIGHT;
    }

}
